﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 时区 添加 修改 
//最后修改: 2010-10-11

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;

namespace TRPOP.CMS.Web.Admin
{
    public partial class TimeZone_save : BaseAdmin
    {

        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_Other;
        }
        #endregion


        #region 页面变量
        protected bool m_IsAdd = true;
        TRPOP.CMS.Model.TimeZoneInfo m_TimeZoneInfo = new TRPOP.CMS.Model.TimeZoneInfo();
        TimeZoneManage m_TimeZoneManage = new TimeZoneManage();
        protected int m_id = 0;
        protected string m_Title = "";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strMSG = "时区名称或时差";
            if (!PageAssist.CheckForm(txtName, ref strMSG) || !PageAssist.CheckForm(txtValue, ref strMSG))
            {
                Alert(strMSG);
                return;
            }

            m_TimeZoneInfo = m_TimeZoneManage.GetInfoById(GetRequestViewState("id").ToInt());
            if (m_TimeZoneInfo == null)
            {
                m_TimeZoneInfo = new TRPOP.CMS.Model.TimeZoneInfo();
            }
            m_TimeZoneInfo.Name = txtName.TextTrim.RemoveHtml();
            m_TimeZoneInfo.TimeLag = txtValue.TextTrim.Tofloat();
            SubmitAlertAndParReset(m_TimeZoneManage.Save(m_TimeZoneInfo));
        }

        #endregion

        #region 页面方法

        public void LoadBase()
        {
            int.TryParse(InitRequestViewState("id"), out m_id);
            m_TimeZoneInfo = m_TimeZoneManage.GetInfoById(m_id);
            if (m_TimeZoneInfo != null)
            {
                m_IsAdd = false;
                m_Title = m_TimeZoneInfo.Name;
                txtName.Text = m_TimeZoneInfo.Name;
                txtValue.Text = m_TimeZoneInfo.TimeLag.ToString();
            }
        }
        #endregion


    }
}
